﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Kira.Compiler.Bods
{
    [XmlElementMapping("CONSTANT")]
    public class Constant : BodsExpression
    {

        public String ValueText
        {
            get { return this.GetAttrbuteValue("value"); }
        }

        public BodsDataType DataType
        {
            get
            {
                return (BodsDataType)Enum.Parse(typeof(BodsDataType), this.GetAttrbuteValue("datatype"), true);
            }
        }

        public int Size
        {
            get { return this.GetAttrbuteIntegerValue("size"); }
        }

        public override string ToString()
        {
            if (this.DataType == BodsDataType.VARCHAR || this.DataType == BodsDataType.DATE || this.DataType == BodsDataType.DATETIME)
            {
                return "'" + this.ValueText + "'";
            }
            return this.ValueText;

        }
    }
}
